{include file="public/nheader"}
<div class="layui-fluid layui-bg-white">
    <form action="{:url()}" class="layui-form layui-form-fixed">
        <div class="layui-form-item">
            <label class="layui-form-label">
                <font color="red">* </font>备注名称
            </label>
            <div class="layui-input-block">
                <input type="text" name="title" required="" lay-verify="required" autocomplete="off" class="layui-input"
                    value="{$row.title|default=''}" placeholder="请填写备注名称">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
                <font color="red">* </font>排序[值越大越靠前]
            </label>
            <div class="layui-input-block">
                <input type="text" name="sort" required="" lay-verify="required" autocomplete="off" class="layui-input"
                    value="{$row.sort|default='0'}" placeholder="排序越大越靠前">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
                <font color="red">* </font>活动类型
            </label>
            <div class="layui-input-block">
                <input type="radio" name="isopen" value="1" title="无" {if !empty($row.isopen) &&
                    $row.isopen==1}checked{/if}>
                <input type="radio" name="isopen" value="2" title="N元洗鞋" {if !empty($row.isopen) &&
                    $row.isopen==2}checked{/if}>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
                <font color="red">* </font>类别
            </label>
            <div class="layui-input-block">
                <input type="radio" name="types" value="1" title="首页轮播" {if !empty($row.types) &&
                    $row.types==1}checked{/if}>
                <input type="radio" name="types" value="2" title="积分商城" {if !empty($row.types) &&
                    $row.types==2}checked{/if}>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
                <font color="red">* </font>类型
            </label>
            <div class="layui-input-block">
                <select name="agentid">
                    <option value="">请选择代理账号</option>
                    <option value="0" {if empty($row.agentid)}selected{/if}>平台(平台添加)</option>
                    {foreach $agent as $v}
                    <option value="{$v.id}" {if !empty($row.agentid) && $row.agentid==$v.id}selected{/if}>
                        {$v.nickname}</option>
                    {/foreach}
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
                <font color="red">* </font>图片
            </label>
            <div class="layui-input-block">
                <button type="button" class="layui-btn" id="test1">上传图片</button>
                <div class="layui-upload-list">
                    <input type="hidden" value="{$row.url|default=''}" name="url" id="covers">
                    <img class="layui-upload-img" id="demo1" src="{$row.url|default=''}"
                        style="width: 200px;height: auto;">
                </div>
            </div>

            <div class="layui-footer layui-form-item layui-center ">
                <input type="hidden" value="{$row['id']|default='0'}" name="id" />
                <button class="layui-btn" lay-filter="submitIframe" type="button" lay-submit>提交</button>
                <button class="layui-btn layui-btn-primary" type="button" sa-event="closeDialog">取消</button>
            </div>
    </form>
</div>
{include file="public/nfooter"}
<script>
    layui.use(['form', 'layer', 'upload'], function () {
        $ = layui.jquery;
        var form = layui.form
            , upload = layui.upload
            , element = layui.element
            , layer = layui.layer;
        //图片上传
        var uploadInst = upload.render({
            elem: '#test1'
            , url: '/base/upload_img'
            , accept: 'images'
            , before: function (obj) {
                layer.load(); //上传loading
            }, done: function (res) {
                //如果上传失败
                if (res.code == 1) {
                    layer.closeAll('loading'); //关闭loading
                    return layer.msg('图片上传失败，请重试');
                }
                if (res.code == 200) {
                    //上传成功
                    $('#demo1').attr('src', res.url); //图片链接（base64）
                    $('#covers').val(res.url);
                    layer.closeAll('loading'); //关闭loading
                    return layer.msg('图片上传成功');
                }
            }
            , error: function () {
                layer.closeAll('loading'); //关闭loading
                return layer.msg(res.msg);
            }
        });
    });
</script>